
local time = achievements.GetValue( "Pale", "total", 0 )

local target = 3600
local function Update()
	local ply = LocalPlayer()
	if ( !ValidEntity( ply ) ) then return end
	local colour = render.GetLightColor( ply:GetShootPos() )
	
	if ( time != target && colour:Length() < 0.4 ) then
		time = math.Clamp( time + 1, 0, target )
		achievements.SetValue( "Pale", "total", time )
		
		if ( time >= target ) then
			timer.Destroy( "Achievements.Pale" )
		end
	end
	
	achievements.Update( "Pale", time / target, achievements.FormatTime( time, "h:m:s" ) )
end
timer.Create( "Achievements.Pale", 1, 0, Update )

achievements.Register( "Pale", "Spend a total of 1 hour in low light conditions.", "achievements/pale", time / target, achievements.FormatTime( time, "h:m:s" ) )